﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Trip/Trip.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="LOGISTCBUS.Entities" %>
<%@ Import Namespace="LOGISTCBUS.DAO" %>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
    <link href="<%= Url.Content("~/Scripts/Plugins/timeentry/jquery.timeentry.css") %>"
        rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="<%= Url.Content("~/Scripts/App/tripEdit.js") %>"></script>
    <script type="text/javascript" src="<%= Url.Content("~/Scripts/Plugins/timeentry/jquery.timeentry.min.js") %>"></script>
    <script type="text/javascript" src="<%= Url.Content("~/Scripts/Plugins/timeentry/jquery.timeentry-pt.js") %>"></script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <strong>CADASTRO DE VIAGEM</strong>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%
        var t = this.ViewData["trip"] != null ? (Trip)this.ViewData["trip"] : new Trip();
    %>
    <div class="box">
        <div class="tabs">
            <ul>
                <li class="titleBox" style="padding: 3px 0 6px 10px;">Preencha os campos abaixo:</li>
            </ul>
            <div style="padding: 20px;" align="center">
                <div class="box" style="width: 500px;">
                    <div class="tabs">
                        <div style="padding: 10px;">
                            <input type="hidden" id="hdfIdTrip" value="<%= t.Id %>" />
                            <img id="loading" src="<%= Url.Content("~/Scripts/Plugins/ajaxfileupload/loading.gif") %>"
                                alt="Carregando" style="display: none;" />
                            <table border="0" align="center" cellpadding="0" cellspacing="5" class="texto10azulclaro">
                                <tr>
                                    <td colspan="3" align="center">
                                        <p style='color: red; font-weight: bold;' id="lblMessage">
                                            <%= ViewData["error"] %>
                                        </p>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Código:
                                    </td>
                                    <td>
                                        <input type="text" name="txtCode" id="txtCode" class="fForm required" maxlength="200"
                                            disabled="disabled" style="width: 220px;" tabindex="1" value="<%= t.Id > 0 ? t.Code : new TripDAO().selectNextCode() %>" />
                                        <input type="hidden" id="hdfCode" value="<%= t.Id > 0 ? t.Code : new TripDAO().selectNextCode() %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Origem:
                                    </td>
                                    <td>
                                        <input type="text" name="txtOrigin" id="txtOrigin" class="fForm required" maxlength="200"
                                            style="width: 220px;" tabindex="2" value="<%= t.Origin %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Destino:
                                    </td>
                                    <td>
                                        <input type="text" name="txtDestination" id="txtDestination" class="fForm required"
                                            maxlength="200" style="width: 220px;" tabindex="3" value="<%= t.Destination %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Data Saída:
                                    </td>
                                    <td>
                                        <input type="text" name="txtBeginDate" id="txtBeginDate" class="fForm datefield"
                                            maxlength="10" style="width: 115px;" tabindex="4" value="<%= t.BeginDate != null ? Convert.ToDateTime(t.BeginDate).ToString("dd/MM/yyyy") : string.Empty %>" />
                                        Horário:
                                        <input type="text" name="txtBeginHour" id="txtBeginHour" class="fForm" maxlength="5"
                                            style="width: 50px;" tabindex="5" value="<%= t.BeginDate != null ? Convert.ToDateTime(t.BeginDate).ToString("HH:mm") : string.Empty %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Data Chegada:
                                    </td>
                                    <td>
                                        <input type="text" name="txtEndDate" id="txtEndDate" class="fForm datefield" maxlength="10"
                                            style="width: 115px;" tabindex="6" value="<%= t.EndDate != null ? Convert.ToDateTime(t.EndDate).ToString("dd/MM/yyyy") : string.Empty %>" />
                                        Horário:
                                        <input type="text" name="txtEndHour" id="txtEndHour" class="fForm" maxlength="5"
                                            style="width: 50px;" tabindex="7" value="<%= t.EndDate != null ? Convert.ToDateTime(t.EndDate).ToString("HH:mm") : string.Empty %>" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Documento:
                                    </td>
                                    <td>
                                        <input type="file" id="txtFile" class="fForm" name="txtFile" size="17" tabindex="8" />
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        &nbsp;
                                    </td>
                                    <td>
                                        <input id="btnAdd" type="button" name="btnAdd" value="Adicionar" class="ui-button ui-state-default ui-corner-all botaoS" />
                                        <input id="btnDel" type="button" name="btnDel" value="Remover" class="ui-button ui-state-default ui-corner-all botaoS" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td>
                                        <select id="cboFiles" class="fForm" style="width: 221px; height: 75px;" multiple="multiple"
                                            tabindex="9">
                                            <%
                                                foreach (var d in new DocumentDAO().selectByTrip(t.Id))
                                                {
                                                    if (!String.IsNullOrEmpty(d.Name))
                                                    {
                                                        var selected = "";
                                            %>
                                            <option <%= selected %> value="<%= d.Id %>">
                                                <%= d.Name %>
                                            </option>
                                            <%      }
                                                }
                                            %>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Clientes:
                                    </td>
                                    <td>
                                        <div style="float: left;">
                                            <select id="cboClientes" class="fForm" style="width: 100px; height: 112px;" multiple="multiple"
                                                tabindex="10">
                                                <%
                                                    foreach (var c in new CustomerDAO().selectByTrip(t.Id, true))
                                                    {
                                                        if (!String.IsNullOrEmpty(c.Name))
                                                        {
                                                            var selected = "";
                                                %>
                                                <option <%= selected %> value="<%= c.Id %>">
                                                    <%= c.Name %>
                                                </option>
                                                <%      }
                                                    }
                                                %>
                                            </select>
                                        </div>
                                        <div style="float: left;">
                                            <ul id='icons' class='ui-widget ui-helper-clearfix'>
                                                <li class='ui-state-default ui-corner-all' title='Mover Todos'><a href='#' id='lnkBackAllCustomer'>
                                                    <span class='ui-icon ui-icon-seek-first'></span></a></li>
                                                <br />
                                                <br />
                                                <li class='ui-state-default ui-corner-all' title='Mover para Direita'><a href='#'
                                                    id='lnkMoveLeftCustomer'><span class='ui-icon ui-icon-seek-prev'></span></a>
                                                </li>
                                                <br />
                                                <br />
                                                <li class='ui-state-default ui-corner-all' title='Mover para Esquerda'><a href='#'
                                                    id='lnkMoveRightCustomer'><span class='ui-icon ui-icon-seek-next'></span></a>
                                                </li>
                                                <br />
                                                <br />
                                                <li class='ui-state-default ui-corner-all' title='Voltar Todos'><a href='#' id='lnkMoveAllCustomer'>
                                                    <span class='ui-icon ui-icon-seek-end'></span></a></li>
                                            </ul>
                                        </div>
                                        <div style="float: right;">
                                            <select id="cboClientesVinculados" class="fForm" style="width: 100px; height: 112px;"
                                                multiple="multiple" tabindex="11">
                                                <%
                                                    foreach (var c in new CustomerDAO().selectByTrip(t.Id, false))
                                                    {
                                                        if (!String.IsNullOrEmpty(c.Name))
                                                        {
                                                            var selected = "";
                                                %>
                                                <option <%= selected %> value="<%= c.Id %>">
                                                    <%= c.Name %>
                                                </option>
                                                <%      }
                                                    }
                                                %>
                                            </select>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Alunos:
                                    </td>
                                    <td>
                                        <div style="float: left;">
                                            <select id="cboAlunos" class="fForm" style="width: 100px; height: 112px;" multiple="multiple"
                                                tabindex="12">
                                                <%
                                                    foreach (var v in new StudentDAO().selectStudents(t.Id, true))
                                                    {
                                                        if (!String.IsNullOrEmpty(v.Name))
                                                        {
                                                            var selected = "";
                                                %>
                                                <option <%= selected %> value="<%= v.Id %>">
                                                    <%= v.Name %>
                                                </option>
                                                <%      }
                                                    }
                                                %>
                                            </select>
                                        </div>
                                        <div style="float: left;">
                                            <ul id='icons' class='ui-widget ui-helper-clearfix'>
                                                <li class='ui-state-default ui-corner-all' title='Mover Todos'><a href='#' id='lnkBackAllStudent'>
                                                    <span class='ui-icon ui-icon-seek-first'></span></a></li>
                                                <br />
                                                <br />
                                                <li class='ui-state-default ui-corner-all' title='Mover para Direita'><a href='#'
                                                    id='lnkMoveLeftStudent'><span class='ui-icon ui-icon-seek-prev'></span></a></li>
                                                <br />
                                                <br />
                                                <li class='ui-state-default ui-corner-all' title='Mover para Esquerda'><a href='#'
                                                    id='lnkMoveRightStudent'><span class='ui-icon ui-icon-seek-next'></span></a>
                                                </li>
                                                <br />
                                                <br />
                                                <li class='ui-state-default ui-corner-all' title='Voltar Todos'><a href='#' id='lnkMoveAllStudent'>
                                                    <span class='ui-icon ui-icon-seek-end'></span></a></li>
                                            </ul>
                                        </div>
                                        <div style="float: right;">
                                            <select id="cboAlunosVinculados" class="fForm" style="width: 100px; height: 112px;"
                                                multiple="multiple" tabindex="13">
                                                <%
                                                    foreach (var v in new StudentDAO().selectStudents(t.Id, false))
                                                    {
                                                        if (!String.IsNullOrEmpty(v.Name))
                                                        {
                                                            var selected = "";
                                                %>
                                                <option <%= selected %> value="<%= v.Id %>">
                                                    <%= v.Name %>
                                                </option>
                                                <%      }
                                                    }
                                                %>
                                            </select>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right">
                                        Veículos:
                                    </td>
                                    <td>
                                        <div style="float: left;">
                                            <select id="cboVeiculos" class="fForm" style="width: 100px; height: 112px;" multiple="multiple"
                                                tabindex="14">
                                                <%
                                                    foreach (var v in new VehicleDAO().selectVehicles(t.Id, true))
                                                    {
                                                        if (!String.IsNullOrEmpty(v.NumberPlate))
                                                        {
                                                            var selected = "";
                                                %>
                                                <option <%= selected %> value="<%= v.Id %>">
                                                    <%= v.NumberPlate %>
                                                </option>
                                                <%      }
                                                    }
                                                %>
                                            </select>
                                        </div>
                                        <div style="float: left;">
                                            <ul id='icons' class='ui-widget ui-helper-clearfix'>
                                                <li class='ui-state-default ui-corner-all' title='Mover Todos'><a href='#' id='lnkBackAll'>
                                                    <span class='ui-icon ui-icon-seek-first'></span></a></li>
                                                <br />
                                                <br />
                                                <li class='ui-state-default ui-corner-all' title='Mover para Direita'><a href='#'
                                                    id='lnkMoveLeft'><span class='ui-icon ui-icon-seek-prev'></span></a></li>
                                                <br />
                                                <br />
                                                <li class='ui-state-default ui-corner-all' title='Mover para Esquerda'><a href='#'
                                                    id='lnkMoveRight'><span class='ui-icon ui-icon-seek-next'></span></a></li>
                                                <br />
                                                <br />
                                                <li class='ui-state-default ui-corner-all' title='Voltar Todos'><a href='#' id='lnkMoveAll'>
                                                    <span class='ui-icon ui-icon-seek-end'></span></a></li>
                                            </ul>
                                        </div>
                                        <div style="float: right;">
                                            <select id="cboVeiculosVinculados" class="fForm" style="width: 100px; height: 112px;"
                                                multiple="multiple" tabindex="15">
                                                <%
                                                    foreach (var v in new VehicleDAO().selectVehicles(t.Id, false))
                                                    {
                                                        if (!String.IsNullOrEmpty(v.NumberPlate))
                                                        {
                                                            var selected = "";
                                                %>
                                                <option <%= selected %> value="<%= v.Id %>">
                                                    <%= v.NumberPlate %>
                                                </option>
                                                <%      }
                                                    }
                                                %>
                                            </select>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="23" align="right" valign="middle">
                                        Descrição:
                                    </td>
                                    <td>
                                        <textarea id="txtDescription" rows="3" cols="100" class="fForm" style="width: 220px;
                                            height: 100px;" maxlength="500" tabindex="16"><%= t.Description %></textarea>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
                <div style="padding-top: 10px;">
                    <input name="btnSave" id="btnSave" type="button" value="Inserir" class="ui-button ui-state-default ui-corner-all botaoS"
                        tabindex="17" />
                </div>
            </div>
        </div>
    </div>
    <div align="center" class="texto10azulclaro" style="padding-top: 15px;">
        © 2012 - Todos os direitos reservados.
    </div>
</asp:Content>
